<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>错题本 - 英语单词测试系统</title>
    <link href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/5.3.0/css/bootstrap.min.css" rel="stylesheet">
    <script src="{{ url_for('static', filename='js/wordcloud2.min.js') }}"></script>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-success">
    <div class="container-fluid">
        <a class="navbar-brand" href="/student">英语单词测试系统</a>
        <div class="d-flex">
            <a href="/logout" class="btn btn-outline-light">退出登录</a>
        </div>
    </div>
</nav>
<div class="container mt-5">
    <h4 class="mb-4">错题本</h4>
    <div class="row mb-4">
        <div class="col-md-8">
            <table class="table table-bordered table-hover align-middle">
                <thead class="table-danger">
                    <tr>
                        <th>单词</th>
                        <th>释义</th>
                        <th>错题次数</th>
                    </tr>
                </thead>
                <tbody>
                    {% for w in wrongs %}
                    <tr>
                        <td>{{ w.word }}</td>
                        <td>{{ w.meaning }}</td>
                        <td>{{ w.count }}</td>
                    </tr>
                    {% endfor %}
                </tbody>
            </table>
        </div>
        <div class="col-md-4">
            <div class="card">
                <div class="card-header bg-danger text-white text-center">错词词云</div>
                <div class="card-body">
                    <div id="wordcloud" style="width:100%;height:250px;"></div>
                </div>
            </div>
        </div>
    </div>
    <a href="/student" class="btn btn-secondary">返回首页</a>
</div>
<script>
    var words = [
        {% for w in wrongs %}
        ["{{ w.word }}", {{ w.count }}, "{{ w.meaning }}"],
        {% endfor %}
    ];
    WordCloud(document.getElementById('wordcloud'), {
        list: words.map(function(item){return [item[0], item[1]];}),
        gridSize: 10,
        weightFactor: 12,
        fontFamily: '微软雅黑',
        color: 'random-dark',
        backgroundColor: '#fff',
        click: function(item, dimension, event){
            var word = item[0];
            var meaning = words.find(function(w){return w[0]===word;})[2];
            var count = item[1];
            alert('单词：'+word+'\n释义：'+meaning+'\n错题次数：'+count);
        }
    });
</script>
</body>
</html> 